﻿using WatiNCF;
using Northwind.Watin.Controllers.Employees;
using Northwind.Watin.Controllers.Products;
using Northwind.Watin.Controllers.Suppliers;
using WatiN.Core;

namespace Northwind.Watin.Controllers
{
    [Url("http://localhost/Northwind", "Default.aspx")]
    public class NorthwindController : HomePageController<NorthwindController>//, IRequiresLogin  
    {
        public EmployeeController EmployeeController
        {
            get { return new EmployeeController(this, this); }
        }

        private SupplierController SupplierController
        {
            get { return new SupplierController(this, this); }
        }


        private ProductController ProductController
        {
            get { return new ProductController(this, this); }
        }


        public EmployeeController GoToEmployees()
        {
            Browser.Link(Find.ByText("Employees")).Click();
            return EmployeeController;
        }

        public SupplierController GoToSuppliers()
        {
            Browser.Link(Find.ByText("Suppliers")).Click();
            return SupplierController;
        }

        public ProductController GoToProducts()
        {
            Browser.Link(Find.ByText("Products")).Click();
            return ProductController;
        }

        #region Login Support
        //public ILoginController<NorthwindController, NorthwindController> LoginController
        //{
        //    get { return new LoginController<NorthwindController, NorthwindController>(this, this); }
        //}

        //public bool IsLoggedIn()
        //{
        //    return LoginController.IsLoggedIn();
        //}

        //public void Login()
        //{
        //    LoginController.Login();
        //}

        //public void Logout()
        //{
        //    LoginController.Logout();
        //}
        #endregion
    }
}
